import random

class memorytable(object):
  data = None

  sector_size_l = None
  last_l = None
  line_f = None
  
  def __init__(self, new_size_l, new_line_f):
    self.sector_size_l = new_size_l
    self.last_l = 0
    self.line_f = new_line_f

    self.data = []

  def add_entry(self, node_id):
    sector_start_l = self.last_l
    self.data.append(node_id)
    self.last_l += self.sector_size_l
    return sector_start_l
  
  def get_max_l(self):
    return self.last_l

  def get_random_l(self):
    return random.randint(0,self.last_l-1)

  def lookup(self, line):
    sector = line / self.sector_size_l
    return self.data[sector]
